<!--
 * @Author: your name
 * @Date: 2021-02-28 20:07:38
 * @LastEditTime: 2021-03-01 19:57:04
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \jianfa-admin\src\page\common\components\addFiles.vue
-->
<template>
  <el-dialog
    :title="`上传文件 ${currentMenu.type == 'img' ? '图片类型' : 'PDF类型'}`"
    :visible="visible"
    v-dialogdrag
    class="avue-dialog"
    width="90%"
    top="2vh"
  >
    <Upload ref="uploadFile" :currentMenu="currentMenu" />
    <span slot="footer" class="dialog-footer">
      <el-button @click="$emit('update:visible', false)">取 消</el-button>
      <el-button type="primary" @click="uploadFile" :loading="loading"
        >确 定 上 传</el-button
      >
    </span>
  </el-dialog>
</template>
<script>
import Upload from "./upload";
export default {
  props: {
    visible: {
      type: Boolean,
      default: false,
    },
    currentMenu: {
      type: Object,
      default: {},
    },
  },
  components: {
    Upload,
  },
  data() {
    return {
      loading: false,
    };
  },
  methods: {
    async uploadFile() {
      this.loading = true;
      const res = await this.$refs["uploadFile"].uploadFiles();
      if (res) {
        this.loading = false;
        this.$emit("update:visible", false);
        this.$emit("getData");
      }
    },
  },
};
</script>
<style lang='scss' scoped>
</style>